package com.tencent.qf.goods.controller;

import com.alibaba.fastjson.JSON;
import com.tencent.qf.common.pojo.HttpResult;
import com.tencent.qf.goods.dto.db.RecommendSpuDto;
import com.tencent.qf.goods.dto.request.RecommendSpuRequest;
import com.tencent.qf.goods.service.DmAppSpuSalesInfoService;
import com.tencent.qf.mybatis.pojo.PageRequest;
import com.tencent.qf.mybatis.pojo.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@Api(value = "SPU交易明细", tags = "SPU交易明细", protocols = "http")
public class DmAppSpuSalesInfoController {

    @Autowired
    private DmAppSpuSalesInfoService dmAppSpuSalesInfoService;


    @PostMapping("/api/goods/recommend/spu")
    @ApiOperation("数据快照获取推荐商品")
    public HttpResult<PageResult<RecommendSpuDto>> recommendSpu(
            @RequestBody PageRequest<RecommendSpuRequest> request) {
        log.info("数据快照获取推荐商品，入参：{}", JSON.toJSONString(request));
        PageResult<RecommendSpuDto> data = dmAppSpuSalesInfoService.recommendSpu(request);
        HttpResult<PageResult<RecommendSpuDto>> result = HttpResult.success(data);
        log.info("数据快照获取推荐商品，出参：{}", JSON.toJSONString(result));
        return result;
    }
}
